//环形链表找入口
https://leetcode.cn/problems/linked-list-cycle-ii/

class Solution {
public:
    ListNode* detectCycle(ListNode* head) 
    {
        ListNode* fast = head, * slow = head;
        while (fast && fast->next)
        {
            fast = fast->next->next;
            slow = slow->next;

            if (fast == slow)
            {
                while (head != slow)
                {
                    head = head->next;
                    slow = slow->next;
                }
                return head;
            }
        }

        return nullptr;
    }
};